# Maintainer: nixfloyd <nixfloyd@gmail.com>
pkgname=prometheus-snmp-exporter
_pkgname=snmp_exporter
pkgver=0.20.0
pkgrel=7
pkgdesc="SNMP Exporter for Prometheus"
url="https://github.com/prometheus/snmp_exporter"
# riscv64: prometheus/procfs needs updating
arch="all !riscv64"
license="Apache-2.0"
makedepends="go net-snmp-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/prometheus/snmp_exporter/archive/v$pkgver.tar.gz
	snmp-exporter.initd
	snmp-exporter.confd
	"
builddir="$srcdir/$_pkgname-$pkgver"

export GOFLAGS="$GOFLAGS -modcacherw -trimpath"

build() {
	go build -o bin/snmp_exporter
	go build -o bin/generator ./generator
}

check() {
	go test
}

package() {
	install -Dm755 bin/snmp_exporter \
		"$pkgdir"/usr/bin/snmp_exporter
	install -Dm755 bin/generator \
		"$pkgdir"/usr/bin/snmp_exporter-generator
	install -Dm644 snmp.yml \
		"$pkgdir"/etc/prometheus/snmp.yml
	install -Dm644 -t "$pkgdir"/usr/share/doc/prometheus-snmp-exporter/ \
		README.md
	install -Dm644 -t "$pkgdir"/usr/share/doc/prometheus-snmp-exporter/examples/ \
		generator/generator.yml
	install -Dm644 -t "$pkgdir"/usr/share/doc/prometheus-snmp-exporter/generator/ \
		generator/README.md
	install -m755 -D "$srcdir"/snmp-exporter.initd \
		"$pkgdir"/etc/init.d/snmp-exporter
	install -m644 -D "$srcdir"/snmp-exporter.confd \
		"$pkgdir"/etc/conf.d/snmp-exporter
}

sha512sums="
fe09033e713f12b5a6ad79445def55c8d94c75cbee5e4e7c4683e853c1a8335005462d607e0c7306d2ee6e70178edeb9b6cff0c35aa6d36a4d0fa5ce45cedb51  prometheus-snmp-exporter-0.20.0.tar.gz
a11085f14e192ff277107dbbb12857a3043dbce1acadbbdf94a88d2b921745f9556cad3c0a81a0113349d322e02b1705831967af3ecc0f95259e759ade9ff5ad  snmp-exporter.initd
489cb298e215bd9647aa5293d456106eb26a73f5fbd9d42fab68de26d273ebb612dba01ba113ce58521b543a2f82a10ad86dc35056ef8d0438b39e77be61f67e  snmp-exporter.confd
"
